;;;Writes a file named <dwgname>.ent with entity layer,
;;;linetype, and color (and block name if its a block).
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://paracadd.com
;;;	All rights reserved.
;;;
(defun c:entlst ()
  (setq entss (ssget)
        count 0
        entss_len (sslength entss)
  )
  (setq ofil (open (strcat(getvar"dwgname")".ent")"w"))
  (while (< count entss_len)
    (setq entdata (entget (ssname entss count)))
    (setq ent_0 (cdr(assoc 0 entdata)))
    (if (eq ent_0 "INSERT")
      (setq ent_2 (cdr(assoc 2 entdata)))
      (setq ent_2 nil)
    )
    (setq ent_8 (cdr(assoc 8 entdata)))
    (if (assoc 62 entdata)
      (if (eq (cdr(assoc 62 entdata))"0")
        (setq ent_62 "BYBLOCK")
        (if (eq (cdr(assoc 62 entdata))"256")
          (setq ent_62 "BYBLOCK")
          (setq ent_62 (itoa(cdr(assoc 62 entdata))))
        )
      )
      (setq ent62 "BYLAYER")
    )
    (if (assoc 6 entdata)
      (setq ent_6 (cdr(assoc 6 entdata)))
      (setq ent_6 "BYLAYER")
    )
    (write-line (strcat ent_0
                        "\t Layer " ent_8
                        "\t Linetype " ent_6
                        "\t Color " ent_62
                        (if ent_2 (strcat "\t Block name: " ent_2)"")
                ) ofil
    )
    (setq count (1+ count))
  )
  (close ofil)
  (princ)
)